package view.content;

import java.awt.BorderLayout;

import javax.swing.JTextArea;

import model.contents.Content;
import model.contents.TextContent;

public class TextBox extends ContentBox {
	private TextContent content;
	private JTextArea textLabel;
	public TextBox(Content c, int width, int height) {
		super(c, width, height);
		if(c instanceof TextContent) {
			this.content = (TextContent)c;
			
			this.textLabel = new JTextArea();
			this.textLabel.setEditable(false);
			this.textLabel.setLineWrap(true);
			this.textLabel.setWrapStyleWord(true);
			this.textLabel.setOpaque(false);
			this.textLabel.setBorder(null);
			this.textLabel.setText(content.getText());
			
			this.setLayout(new BorderLayout());
			this.add(this.textLabel, BorderLayout.CENTER);
			this.setOpaque(false);
			
			applyFormat();
		}
	}
	private void applyFormat() {
		LabelFormat format = new LabelFormat(content.getFormat());
		format.applyStyle(this.textLabel);
	}

}
